<template>
  <el-container>
    <el-header>
      <div class="header-title">
        <i class="el-icon-s-promotion" :size="60"></i>
        <span>后台管理系统</span>
      </div>
      <el-menu mode="horizontal" background-color="#334157" text-color="#9fa6b0" active-text-color="#9fa6b0">
        <el-submenu index="1">
          <template slot="title">
            我的工作台
          </template>
          <el-menu-item index="1">个人信息</el-menu-item>
          <el-menu-item index="2">修改密码</el-menu-item>
          <el-menu-item index="3">退出</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-header>
    <el-container>
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <el-radio-group v-model="isCollapse" size="small">
          <el-radio-button :label="false">展开</el-radio-button>
          <el-radio-button :label="true">收起</el-radio-button>
        </el-radio-group>
        <el-menu :collapse="isCollapse" background-color="#334157" text-color="#fff" active-text-color="#409EFF" :router="true">
          <el-submenu v-for="item in menuList" :index="item.Id" :key="item.Id">
            <template slot="title">
              <i :class="item.MenuIcon"></i>
              <span>{{item.MenuName}}</span>
            </template>
            <el-menu-item  v-for="item in item.Children" :index="item.MenuPath" :key="item.Id">
              <template slot="title">
                <i class="iconfont icon-caidan"></i>
                <span>{{item.MenuName}}</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false,
      menuList: []
    }
  },
  mounted() {
    this.getMenus()
  },
  methods: {
    async getMenus() {
      const res = await this.$http.get('menus')
      this.menuList = res
    }
  }
}
</script>

<style scoped lang="less">
.el-container {
  height: 100%;
}
.el-header,
.el-aside {
  background-color: #334157;
}
.el-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #9fa6b0;
  .header-title {
    display: flex;
    align-items: center;
    font-size: 20px;
    i {
      font-size: 40px;
      margin-right: 15px;
    }
  }
  .el-menu {
    border-bottom: 0;
  }
}
.el-container {
  .el-radio-group {
    margin-bottom: 20px;
    margin-left: 10px;
  }
  .el-menu {
    border-right: 0;
    .iconfont{
      margin-right: 10px;
    }
  }
}
</style>
